#ifndef _UTILITY_H_
#define _UTILITY_H_

#define SEM_NAME "mysem"
#define SHARE_FILE "shareFile"

typedef struct _SHARE_HEAD_ {
    unsigned int ridx;
    unsigned int widx;
    unsigned int totalLen;
    volatile char *pAddr1;
    volatile char *pAddr2;
}SHARE_HEAD;

#define SHR_STRU "shrStru"
#define SHR_FILE_BUF "shrFileBuf"
#define SHR_BUF_LEN 4096*1024


/* Evaluates to the same boolean value as 'p', and hints to the compiler that
 * we expect this value to be false. */
#if defined(__GNUC__) && __GNUC__ >= 3         /* gcc 3.0 or later */
#define EVUTIL_UNLIKELY(p) __builtin_expect(!!(p),0)
#else
#define EVUTIL_UNLIKELY(p) (p)
#endif

/* Replacement for assert() that calls event_errx on failure. */
#ifdef NDEBUG
#define UTIL_ASSERT(cond) _EVUTIL_NIL_CONDITION(cond)
#define UTIL_FAILURE_CHECK(cond) 0
#else
#define UTIL_ASSERT(cond)						\
	do {								\
		if (EVUTIL_UNLIKELY(!(cond))) {				\
			(void)fprintf(stderr,				\
			    "%s:%d: Assertion %s failed in %s,errno(%d):[%s]",		\
			    __FILE__,__LINE__,#cond,__func__,errno,strerror(errno));		\
			abort();					\
		}							\
	} while (0)
#define UTIL_FAILURE_CHECK(cond) EVUTIL_UNLIKELY(cond)
#endif

#endif